class GenericAPIView(object):
    """封装的类视图"""
    queryset = None
    serializer_class = None

    def get_queryset(self):
        """
        获取所有的查询集
        """
        return self.queryset

    def get_object(self):
        """
        获取查询集中的单一数据
        :return:
        """
        for instance in self.queryset:
            if instance.id == 1:  # 意思一下
                return instance

    def get_serializer(self, data=None):
        """
        获取指定序列化器对象
        :return:
        """

        serializer = self.get_serializer_class()
        return serializer(data=None)

    def get_serializer_class(self):
        """
        返回序列化器
        里面肯定是有一堆判断
        :return:
        """
        return self.serializer_class()
